AWSM_HOME = /home/ls3/workspace/AWSM-gSOAP_googlecode
MAKE = make
CC = gcc
GSOAP_HOME = ${AWSM_HOME}/gsoap
BUILD_HOME = ${AWSM_HOME}/build
INCLUDE = -I/usr/include/libxml2 -I${GSOAP_HOME}
LDFLAGS = -lxml2 -lz -lm -lpthread -luuid -ldl -L${BUILD_HOME}/lib -Wl,--rpath,${BUILD_HOME}/lib
SLDFLAGS = -fPIC -shared
LIBRARYDIRS = libfactory libservice libstate libgenericFactory
SVCDIRS = factoryFinder stateStore genericFactory test

all: test
	cp config.xml ${BUILD_HOME};
	cp start stop ${BUILD_HOME}/bin;
	${CC} ${INCLUDE} -o${BUILD_HOME}/bin/register ${LDFLAGS} -lfactory -lservice register.c
	
test: libgeneric
	${GSOAP_HOME}/soapcpp2 -c AWSMReporter.h -d${BUILD_HOME}/AWSMReporter > /dev/null 2>&1; \
	${CC} ${INCLUDE} -o${BUILD_HOME}/bin/AWSMReporter AWSMReporter.c ${BUILD_HOME}/AWSMReporter/soapC.c ${BUILD_HOME}/AWSMReporter/soapServer.c \
	${GSOAP_HOME}/stdsoap2.c ${LDFLAGS} -lfactory -lservice;

libgeneric: genericFactory
	${CC} ${INCLUDE} -o${BUILD_HOME}/lib/libgenericFactory.so ${SLDFLAGS} \
	libgenericFactory.c ${BUILD_HOME}/genericFactory/soapC.c ${BUILD_HOME}/genericFactory/soapClient.c ${GSOAP_HOME}/stdsoap2.c;

genericFactory: libfactory
	${GSOAP_HOME}/soapcpp2 -c genericFactory.h -d${BUILD_HOME}/genericFactory> /dev/null 2>&1 ;\
	${CC} ${INCLUDE} -o${BUILD_HOME}/bin/genericFactory  ${LDFLAGS} -lservice \
	genericFactory.c ${BUILD_HOME}/genericFactory/soapC.c ${BUILD_HOME}/genericFactory/soapServer.c ${GSOAP_HOME}/stdsoap2.c;

libfactory: libstate factoryFinder
	${CC} ${INCLUDE} -o${BUILD_HOME}/lib/libfactory.so libfactory.c ${BUILD_HOME}/factoryFinder/soapC.c ${BUILD_HOME}/factoryFinder/soapClient.c ${GSOAP_HOME}/stdsoap2.c \
 	${SLDFLAGS} -rdynamic ${LDFLAGS} -lstate 

libstate: stateStore
	${CC} ${INCLUDE} -o${BUILD_HOME}/lib/libstate.so libstate.c ${BUILD_HOME}/stateStore/soapC.c ${BUILD_HOME}/stateStore/soapClient.c ${GSOAP_HOME}/stdsoap2.c \
	${SLDFLAGS}

factoryFinder: libservice
	${GSOAP_HOME}/soapcpp2 -c factoryFinder.h -d${BUILD_HOME}/factoryFinder> /dev/null 2>&1; \
	${CC} ${INCLUDE} -o${BUILD_HOME}/bin/factoryFinder factoryFinder.c ${BUILD_HOME}/factoryFinder/soapC.c ${BUILD_HOME}/factoryFinder/soapServer.c \
	${GSOAP_HOME}/stdsoap2.c ${LDFLAGS} -lservice;
	
stateStore: libservice
	${GSOAP_HOME}/soapcpp2 -c stateStore.h -d${BUILD_HOME}/stateStore> /dev/null 2>&1; \
	${CC} ${INCLUDE} -o${BUILD_HOME}/bin/stateStore stateStore.c ${BUILD_HOME}/stateStore/soapC.c ${BUILD_HOME}/stateStore/soapServer.c \
	${GSOAP_HOME}/stdsoap2.c ${LDFLAGS} -lservice;
	
libservice:
	${CC} ${INCLUDE} -o${BUILD_HOME}/lib/libservice.so libservice.c ${SLDFLAGS} ${LDFLAGS}

